#include "include.h"

#ifdef RUN_TESTS

#include "app/appmain.h"
#include "gui/graphicview.h"
#include "model/floor.h"


#include "compile/debug_memoryleaks"
using namespace gui;
using namespace app;
using namespace model;


BOOST_AUTO_TEST_SUITE(GUI_TEST_SUITE);

struct test_gui_data
{
    app::AppMain appmain;
    GraphicPainter* painter;
    GraphicView*  view;

    test_gui_data()
    {
        int argc=0;
        appmain.init(argc,NULL);

        view = appmain.getGui().getGraphicView();
		assert(view!=NULL);

        painter = view->getGraphicPainter();
    }

    ~test_gui_data()
    {
        appmain.done();
    }
};

BOOST_AUTO_TEST_CASE( painting_on_widget )
{
	test_gui_data data;

	BOOST_TEST_MESSAGE( "Painting DOT widget " );
	data.painter->drawPoint(Vector(100,100));
	data.view->redraw();

/*
	int btn;
	std::cin >> btn;
	while(btn>0)
	{
        data.painter->drawPoint(Vector(100,100)+Vector(btn,btn));
        data.view->redraw();
        std::cin >> btn;
    }
*/

    BOOST_TEST_MESSAGE( "Painting TEXT on widget " );
    data.painter->drawTextH(10,10,100,100, "CIAO");
	data.view->redraw();

    int ret = data.appmain.run();
}


BOOST_AUTO_TEST_CASE( moving_floor)
{
	BOOST_TEST_MESSAGE( "Moving FLOOR on widget " );
	test_gui_data data;

    Vector v1(0,0,0);
    Vector v2(50,50,0);
    model::Floor floor(v1, v2);
    data.appmain.getRoot().getModel().addChild( &floor );

    data.view->redraw();

	while ( floor.topleft.isInWindow(Vector(0,0), Vector(data.view->getWidth(),data.view->getHeight()) ) )
	{
		floor.topleft.move(Vector(0.5,0.5,0));
		floor.bottomright.move(Vector(0.5,0.5,0));
		data.view->redraw();
	}

    //int ret = data.appmain.run();
}

BOOST_AUTO_TEST_SUITE_END();

#endif
